//
//	HomeTodayListModel.swift
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport

import Foundation 
import ObjectMapper

enum BBPlanStatus: Int {
    case idle = 0
    case inProgress
    case complete
    case timeout
    
    var toString: String {
        switch self {
        case .idle:
            return "未开始"
        case .inProgress:
            return "未完成"
        case .complete:
            return "已完成"
        case .timeout:
            return "已超时"
        }
    }
}

class HomeTodayListModel : NSObject, NSCoding, Mappable{

	var actionType : Int?
	var createTime : String?
	var createUser : Int?
	var id : Int?
	var isDeleted : Int?
	var isTimeConflict : Int?
	var planDate : String?
	var planEndTime : String?
	var planId : Int?
	var planLevel : Int?
	var planName : String?
	var planNeedTime : Int?
	var planStartTime : String?
	var planStatus : Int?
	var planType : Int?
	var sort : Int?
	var updateTime : String?
	var updateUser : Int?
	var userId : Int?
	var version : Int?

    
    func getPlanStatus() -> BBPlanStatus {
        var status = BBPlanStatus.idle
        if let planS = planStatus, let bbstatus = BBPlanStatus(rawValue: planS) {
            status = bbstatus
        }
        return status
    }

	class func newInstance(map: Map) -> Mappable?{
		return HomeTodayListModel()
	}
	required init?(map: Map){}
	private override init(){}

	func mapping(map: Map)
	{
		actionType <- map["actionType"]
		createTime <- map["createTime"]
		createUser <- map["createUser"]
		id <- map["id"]
		isDeleted <- map["isDeleted"]
		isTimeConflict <- map["isTimeConflict"]
		planDate <- map["planDate"]
		planEndTime <- map["planEndTime"]
		planId <- map["planId"]
		planLevel <- map["planLevel"]
		planName <- map["planName"]
		planNeedTime <- map["planNeedTime"]
		planStartTime <- map["planStartTime"]
		planStatus <- map["planStatus"]
		planType <- map["planType"]
		sort <- map["sort"]
		updateTime <- map["updateTime"]
		updateUser <- map["updateUser"]
		userId <- map["userId"]
		version <- map["version"]
		
	}

    /**
    * NSCoding required initializer.
    * Fills the data from the passed decoder
    */
    @objc required init(coder aDecoder: NSCoder)
	{
         actionType = aDecoder.decodeObject(forKey: "actionType") as? Int
         createTime = aDecoder.decodeObject(forKey: "createTime") as? String
         createUser = aDecoder.decodeObject(forKey: "createUser") as? Int
         id = aDecoder.decodeObject(forKey: "id") as? Int
         isDeleted = aDecoder.decodeObject(forKey: "isDeleted") as? Int
         isTimeConflict = aDecoder.decodeObject(forKey: "isTimeConflict") as? Int
         planDate = aDecoder.decodeObject(forKey: "planDate") as? String
         planEndTime = aDecoder.decodeObject(forKey: "planEndTime") as? String
         planId = aDecoder.decodeObject(forKey: "planId") as? Int
         planLevel = aDecoder.decodeObject(forKey: "planLevel") as? Int
         planName = aDecoder.decodeObject(forKey: "planName") as? String
         planNeedTime = aDecoder.decodeObject(forKey: "planNeedTime") as? Int
         planStartTime = aDecoder.decodeObject(forKey: "planStartTime") as? String
         planStatus = aDecoder.decodeObject(forKey: "planStatus") as? Int
         planType = aDecoder.decodeObject(forKey: "planType") as? Int
         sort = aDecoder.decodeObject(forKey: "sort") as? Int
         updateTime = aDecoder.decodeObject(forKey: "updateTime") as? String
         updateUser = aDecoder.decodeObject(forKey: "updateUser") as? Int
         userId = aDecoder.decodeObject(forKey: "userId") as? Int
         version = aDecoder.decodeObject(forKey: "version") as? Int

	}

    /**
    * NSCoding required method.
    * Encodes mode properties into the decoder
    */
    @objc func encode(with aCoder: NSCoder)
	{
		if actionType != nil{
			aCoder.encode(actionType, forKey: "actionType")
		}
		if createTime != nil{
			aCoder.encode(createTime, forKey: "createTime")
		}
		if createUser != nil{
			aCoder.encode(createUser, forKey: "createUser")
		}
		if id != nil{
			aCoder.encode(id, forKey: "id")
		}
		if isDeleted != nil{
			aCoder.encode(isDeleted, forKey: "isDeleted")
		}
		if isTimeConflict != nil{
			aCoder.encode(isTimeConflict, forKey: "isTimeConflict")
		}
		if planDate != nil{
			aCoder.encode(planDate, forKey: "planDate")
		}
		if planEndTime != nil{
			aCoder.encode(planEndTime, forKey: "planEndTime")
		}
		if planId != nil{
			aCoder.encode(planId, forKey: "planId")
		}
		if planLevel != nil{
			aCoder.encode(planLevel, forKey: "planLevel")
		}
		if planName != nil{
			aCoder.encode(planName, forKey: "planName")
		}
		if planNeedTime != nil{
			aCoder.encode(planNeedTime, forKey: "planNeedTime")
		}
		if planStartTime != nil{
			aCoder.encode(planStartTime, forKey: "planStartTime")
		}
		if planStatus != nil{
			aCoder.encode(planStatus, forKey: "planStatus")
		}
		if planType != nil{
			aCoder.encode(planType, forKey: "planType")
		}
		if sort != nil{
			aCoder.encode(sort, forKey: "sort")
		}
		if updateTime != nil{
			aCoder.encode(updateTime, forKey: "updateTime")
		}
		if updateUser != nil{
			aCoder.encode(updateUser, forKey: "updateUser")
		}
		if userId != nil{
			aCoder.encode(userId, forKey: "userId")
		}
		if version != nil{
			aCoder.encode(version, forKey: "version")
		}

	}

}
